package tech.aistar.controller;

import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.aistar.entity.LoginFormVo;
import tech.aistar.service.UserService;
import tech.aistar.util.Result;

/**
 * 本类用来演示:
 *
 * @author jyz
 * @date 2023/3/11 22:41:55
 */
@RestController
@RequestMapping( "/login")
public class UserController {
    @Resource
    private UserService userService;

    /**
     * 发送手机验证码
     * @param phone
     * @param session
     * @return
     */
    @RequestMapping(value ="/sendCode")
    public Result sendCode(String phone, HttpSession session){
        return userService.sendCode(phone,session);
    }

    /**
     * 登录
     * @param loginFormVo
     * @param session
     * @return
     */
    @RequestMapping(value ="/logined")
    public Result login(LoginFormVo loginFormVo, HttpSession session){
        return userService.login(loginFormVo,session);
    }

    /**
     * 获取信息
     * @return
     */
    @RequestMapping(value ="/get")
    public Result getInfo(){
        return userService.getInfo();
    }

    /**
     * 测试，不认证看是否会拦截,这个是默认跳转到authentication.html页面
     * @return
     */
    @RequestMapping(value ="/authentication")
    public Result authentication(){
        return Result.ok();
    }
    /**
     * 测试，不认证看是否会拦截,这个是跳转到index.html页面
     * @return
     */
    @RequestMapping(value ="/index")
    public Result index(){
        return Result.ok();
    }
}
